
#ifndef __LIBERTY_ENGINE_WINDOWS_STREAM_H__
#define __LIBERTY_ENGINE_WINDOWS_STREAM_H__

#include <streambuf>

namespace Liberty { namespace Engine {
    public ref class StreamBuf_To_Stream abstract : public System::IO::Stream {
    protected:
        std::streambuf* _buf;

    public:
        StreamBuf_To_Stream(std::streambuf* buf);

        property bool CanSeek {
            virtual bool get() override;
        }

        property __int64 Position {
            virtual __int64 get() override;
            virtual void set(__int64 p) override;
        }

        property __int64 Length {
            virtual __int64 get() override;
        }

        virtual void Flush() override;

        virtual void SetLength(__int64 p) override;

        virtual __int64 Seek(__int64 p, System::IO::SeekOrigin origin) override;

        virtual int Read(array<unsigned char>^ buffer, int offset, int count) override;
        virtual void Write(array<unsigned char>^ buffer, int offset, int count) override;
    };

    public ref class StreamBuf_To_InputStream : public StreamBuf_To_Stream {
    public:
        StreamBuf_To_InputStream(std::streambuf* buf);

    public:
        property bool CanRead {
            virtual bool get() override;
        }

        property bool CanWrite {
            virtual bool get() override;
        }
    };

    public ref class StreamBuf_To_OutputStream : public StreamBuf_To_Stream {
    public:
        StreamBuf_To_OutputStream(std::streambuf* buf);

    public:
        property bool CanRead {
            virtual bool get() override;
        }

        property bool CanWrite {
            virtual bool get() override;
        }
    };

    System::IO::Stream^ CreateInputStream(std::streambuf*);
    System::IO::Stream^ CreateOutputStream(std::streambuf*);
}}

#endif
